#ifndef BOT_H_
#define BOT_H_

#include "State.h"
/*
    This struct represents your bot in the game of Ants
*/
struct Bot
{
    State state;

    Bot();

    int* hills;
    int ants, seenArea;

    int rows, cols;
    int *enemyMap;
    bool *seen, *moved, *water, *safe, *designated, *occupied;
    void initialize();	
    void update(struct visSquare *vs, int col, int row);			// Updates the reward of each square in the visible area of an ant
    void setWaterReward(struct visSquare *vs);
    void foodBFS(struct visSquare *vs, int col, int row);
    void viewBFS(struct visSquare *vs, int col, int cow);
    bool isFriend(int r, int c, int direction);
    int getReward(struct visSquare *vs, int r, int c, int direction);			// Returns the reward of a particular square
    void setReward(struct visSquare *vs, int r, int c, int direction, int reward);	// Sets the reward of a particular square
    int getOpportunity(struct visSquare *vs, int r, int c, int direction);
    
    void updateHills();                                                                 // update newly seen hills and cancel destroyed hills
    
    int nearbyMyHill(int row, int col, int r);
    int nearbyEnemies(int row, int col, int r);
    bool needReinforcement(int row, int col);

    void setOpportunity(struct visSquare * vs, int row, int col, int value);
    void addOpportunity(struct visSquare *vs, int row, int col, int value);

    // The following functions set up reward of enemies
    void cluster(int &counter);
    bool inCluster(int r, int c, int &clusterNo);
    void setEnemyReward(struct visSquare *vs);
    
    int opponents, *totalInfluence, *influence, *fight, *moveTo;
    bool *opportunitySet;
    void setAttackOpportunity(struct visSquare *vs);
    void calOpportunity(struct visSquare *vs, int row, int col, int direction);
    int bestEnemy(int row, int col, int &weakest);
    void setFight();
    void calFight(int player, int row, int col, int direction);
    void addInfluence(int player, int row, int col);
    int adjacentAnt(int row, int col);

    void playGame();    //plays a single game of Ants
    void makeMoves();   //makes moves for a single turn
    void endTurn();     //indicates to the engine that it has made its moves

    struct nearbyPoint{
	int row, col, distance;
    };
};

struct moveQueue{
	int row, col, utility, dir;
};

class sequenceSorter{
public:
	bool operator() (const moveQueue &move1, const moveQueue &move2){
		return move1.utility < move2.utility;
	};
};

struct bfsSquare{
	int row, col, dis, lastDir;
};

#endif //BOT_H_
